Add a test that reproduces the error of parsing home config twice.
authorJuan Hernández <juan.hernandez.babon@gmail.com>
Thu, 8 Sep 2016 19:13:31 +0000 (15:13 -0400)
committerJuan Hernández <juan.hernandez.babon@gmail.com>
Thu, 8 Sep 2016 19:13:31 +0000 (15:13 -0400)
tests/cargotest/support/mod.rs
tests/rustflags.rs

index c99e8e294a00ba026c44fcb8cc8aea94f444a7a3..fb6c7daf6296108d138ad399236b413cb5126031 100644 (file)
@@ -198,6 +198,11 @@ pub fn project(name: &str) -> ProjectBuilder {
     ProjectBuilder::new(name, paths::root().join(name))
 }
 
+// Generates a project layout inside our fake home dir
+pub fn project_in_home(name: &str) -> ProjectBuilder {
+    ProjectBuilder::new(name, paths::home().join(name))
+}
+
 // === Helpers ===
 
 pub fn main_file(println: &str, deps: &[&str]) -> String {
index 264c47219ef92dd04a1968d372318a2a0e8787aa..ccdc6a91dc92d814f82ea944741b87cf9b199cf8 100644 (file)
@@ -5,7 +5,7 @@ use std::io::Write;
 use std::fs::{self, File};
 
 use cargotest::rustc_host;
-use cargotest::support::{project, execs, paths};
+use cargotest::support::{project, project_in_home, execs, paths};
 use hamcrest::assert_that;
 
 #[test]
@@ -852,3 +852,29 @@ fn build_rustflags_no_recompile() {
     assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
                 execs().with_stdout("").with_status(0));
 }
+
+#[test]
+fn build_rustflags_with_home_config() {
+    // We need a config file inside the home directory
+    let home = paths::home();
+    let home_config = home.join(".cargo");
+    fs::create_dir(&home_config).unwrap();
+    File::create(&home_config.join("config")).unwrap().write_all(br#"
+        [build]
+        rustflags = ["-Cllvm-args=-x86-asm-syntax=intel"]
+    "#).unwrap();
+
+    // And we need the project to be inside the home directory
+    // so the walking process finds the home project twice.
+    let p = project_in_home("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.0.1"
+        "#)
+        .file("src/lib.rs", "");
+    p.build();
+
+    assert_that(p.cargo("build").arg("-v"),
+                execs().with_status(0));
+}